package com.yantong.controller.api;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yantong.annotation.Auth;
import com.yantong.constant.ProductType;
import com.yantong.controller.BaseController;
import com.yantong.enums.MarketingGroupTypeEnum;
import com.yantong.exception.BDException;
import com.yantong.mapper.CollectMapper;
import com.yantong.mapper.OrderProductMapper;
import com.yantong.mapper.ProductSkuCentreMapper;
import com.yantong.pojo.*;
import com.yantong.pojo.vo.*;
import com.yantong.result.ResultVo;
import com.yantong.service.*;
import com.yantong.utils.ObjectUtils;
import com.yantong.utils.PageUtils;
import com.yantong.utils.ValidateUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.util.HtmlUtils;
import springfox.documentation.annotations.ApiIgnore;

import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;

/**
 * @author: juzi
 * @date: 2021/10/25
 * @time: 16:12
 */
@ApiIgnore
@Controller
@RequestMapping("/wxapi/shop")
public class ShopController extends BaseController {


    @Autowired
    private ProductCentreService productCentreService;
    @Autowired
    private CollectMapper collectMapper;
    @Autowired
    private OrderProductMapper orderProductMapper;
    @Autowired
    private ActivityService activityService;
    @Autowired
    private ProductSkuCentreMapper productSkuCentreMapper;
    @Autowired
    private MarketingGroupService marketingGroupService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private ProductCommentService productCommentService;
    @Autowired
    private MemberService memberService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private AdvertService advertService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private NoticeService noticeService;
//    @Autowired
//    private NodirectService nodirectService;
    @Autowired
    private ConfigService configService;




    /**
     * 商品详情
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/products/detail")
    @ResponseBody
    public ResultVo getProductDetail(Long memberId, Long productId, Long orderId, Integer orderType, Long activityId, Integer marketingGroupType) throws IllegalAccessException {
        ProductCentre detail = null;
        Activity activity = null;
        if (marketingGroupType == null) {
            detail = productCentreService.getProductDetail(productId);
            if (detail == null) {
                return ResultVo.error("抱歉，商品已经下架了");
            }
            CollectVo collectVo = collectMapper.selectbymidAndValueId(memberId, productId.intValue());
            if (collectVo != null) {
                detail.setIsCollect(1);
            }

        } else {
            MarketingGroup marketingGroup = marketingGroupService.getMarketingGroupById(activityId);
            if (marketingGroup != null) {
                if (MarketingGroupTypeEnum.GIFT_BAG.getCode().equals(marketingGroup.getMarketingGroupType())) {
                    activity = activityService.getActivityById(marketingGroup.getProductId());
                    if (activity == null) {
                        return ResultVo.error("抱歉，商品已经下架了");
                    }
                    activity.setProductName(activity.getActivityName());
                } else {
                    detail = productCentreService.getProductDetail(marketingGroup.getProductId());
                    if (detail == null) {
                        return ResultVo.error("抱歉，商品已经下架了");
                    }
                }
            }
        }


        //拼团商品才需要统计
        if (orderType != null && ProductType.Spellgroup.getType() == orderType & orderId != null) {
            List<OrderProduct> orderProducts = orderProductMapper.getByOrderId(orderId);
            if (detail != null) {
                detail.setOrderProducts(orderProducts);
            } else {
                activity.setOrderProducts(orderProducts);
            }

            if (ValidateUtil.isNotEmptyCollection(orderProducts)) {
                if (orderProducts.get(0).getSkuId() != null) {
                    List<ProductSkuCentre> skus = new ArrayList<>();
                    ProductSkuCentre productSkuCentre = productSkuCentreMapper.selectByPrimaryKey(orderProducts.get(0).getSkuId());
                    skus.add(productSkuCentre);
                    detail.setSkus(skus);
                }

                MarketingGroup marketingGroup = marketingGroupService.getMarketingGroupById(orderProducts.get(0).getActivityId());
                if (null != marketingGroup) {
                    if (detail != null) {
                        detail.setProductId(detail.getId());
                        detail.setId(marketingGroup.getId());
                    } else {
                        activity.setProductId(activity.getId());
                        activity.setId(marketingGroup.getId());
                    }
                    //拼团订单数据
                    List<SpellGroupOrdVo> sgOrds = null;
                    //没有订单ID的情况下取的是商品详情，获取到
//                if (orderId == null) {
//                    SpellGroupOrdVo vo = new SpellGroupOrdVo();
//                    vo.setProductId(detail.getId());//拼团商品id
//                    vo.setPeoplenum(marketingGroup.getNeedJoinGroupNum());//拼团商品人数
//                    //查询拼团中的订单
//                    sgOrds = orderService.getSpellGroupOrd(vo);
//                } else {
                    Order order = orderService.getByKey(orderId);
                    if (null != order && ProductType.Spellgroup.getType() == order.getOrderType()) {
                        //先设置为正常
//                detail.setSpellgroupStu(OrderSpellGroupStatus.SPELL_GROUPING.getCode());
                        //分享拼团的商品详情
                        sgOrds = orderService.getSpellGroupOrdById(order.getSgorderId());
                        SpellGroupOrdVo vo = new SpellGroupOrdVo();
                        vo.setMid(memberId);
                        vo.setSgorderId(orderId);
                        //查询是否参团
                        List<Order> list = orderService.getSpellGroupOrdByMid(vo);
                        if (detail != null) {
                            detail.setIsJoin(CollectionUtils.isNotEmpty(list) ? 1 : 2);//1已参加 2未参加
                        } else {
                            activity.setIsJoin(CollectionUtils.isNotEmpty(list) ? 1 : 2);//1已参加 2未参加.setIsJoin(CollectionUtils.isNotEmpty(list) ? 1 : 2);//1已参加 2未参加
                        }

                        if (!sgOrds.isEmpty()) {
                            if (marketingGroup == null) {
                                throw new BDException("拼团活动不存在");
                            }
                            //拼团价格
                            if (detail != null) {
                                detail.setMarketprice(order.getPayprice());
                                detail.setSpellgroupStu(order.getSpellgroupStu());
                            } else {
                                activity.setMarketprice(order.getPayprice());
                                activity.setSpellgroupStu(order.getSpellgroupStu());
                            }

//                    //已结束
//                    if (new Date().after(marketingGroup.getEndTime())) {
//                        detail.setSpellgroupStu(order.getSpellgroupStu());
//                        //已满团
//                    } else if (sgOrds.get(0).getSpellgroupnum() != null && sgOrds.get(0).getSpellgroupnum() >= detail.getSpellgroupnum()) {
//                        detail.setSpellgroupStu(3);
//                    }
                        }
                    }

                    for (SpellGroupOrdVo spellGroupOrdVo : sgOrds) {
                        OrderProductDetailVo orderProductVo = new OrderProductDetailVo();
                        orderProductVo.setId(spellGroupOrdVo.getOrderid());
                        //查找参与拼团订单的头像
                        List<SpellGroupOrdVo> heads = orderService.getGroupOrdHead(orderProductVo);
                        if (CollectionUtils.isNotEmpty(heads)) {
                            spellGroupOrdVo.setAvatars(heads);
                        }
                    }
        	 /* OrderProductVo opVo = new OrderProductVo();
        	  opVo.setProductId(productId);
        	  //查找拼团商品的所有头像
        	  SpellGroupOrdVo  sg =  orderService.getGroupOrdHead(opVo);
        	  if(sg != null) {
        	   detail.setAvatars(sg.getAvatar()==null?null:sg.getAvatar());
        	  }*/
                    //拼团商品订单 在拼团中的
                    if (detail != null) {
                        detail.setSpellGroupOrdS(sgOrds);
                    } else {
                        activity.setSpellGroupOrdS(sgOrds);
                    }

                    if (null != marketingGroup) {
                        if (detail != null) {
                            detail.setUpStartTime(marketingGroup.getStartTime());
                            detail.setUpEndTime(marketingGroup.getEndTime());
                            //detail.setVipprice(marketingGroup.getVipPrice());
                        } else {
                            activity.setUpStartTime(marketingGroup.getStartTime());
                            activity.setUpEndTime(marketingGroup.getEndTime());
                        }

                    }
//                }
                } else {
                    throw new BDException("未找到该拼团商品，该拼团商品可能已被删除！");
                }
            }
        }
        //查询最新的评论
        ProductCommentVo commentVo = productCommentService.getNewComentByProductId(productId);
        if (detail != null) {
            detail.setComent(commentVo);
            detail.setComentCount(productCommentService.countComentCountByProductId(productId));
        } else {
            activity.setComent(commentVo);
            activity.setComentCount(productCommentService.countComentCountByProductId(productId));
        }

        CommanerVo vo = memberService.getCommanderByMembId(memberId);//通过会员Id查询门店信息
        //门店id
        if (detail != null) {
            CommanerVo liansuoVo = memberService.getCommanderByMembId(detail.getLiansuoid());//通过会员Id查询门店信息
            if (null != liansuoVo) {
                detail.setLiansuoVo(liansuoVo);
            }
        }

        //int cartNum = productCentreService.getProductInCartNum(memberId, productId);
        JSONObject jsonObject = (JSONObject) JSON.toJSON(detail == null ? activity : detail);
        String s = redisTemplate.opsForValue().get("cardTotal:" + memberId + ":" + productId);
        String s1 = s == null ? "0" : s;
        jsonObject.put("cartNum", Integer.parseInt(s1));
        if (vo != null) jsonObject.putAll(ObjectUtils.objectToMap(vo));
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", jsonObject);
        resultVo.put("time", System.currentTimeMillis());
        return resultVo;
    }

    /**
     * 商品评价详情
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/products/detail/comments")
    @ResponseBody
    public ResultVo getProductComments(Long productId, Integer type, Integer level, Integer offset, Integer limit) {
        ProductDetailCommentResqVo resqVo = new ProductDetailCommentResqVo();
        //查询商品评论列表
        Map params = new HashMap();
        params.put("level", level);
        params.put("offset", (offset - 1) * limit);
        params.put("limit", limit);
        //不带type默认为普通商品
        if (type == null) {
            type = 0;
        }
        params.put("type", type);
        params.put("productId", productId);
        PageUtils<ProductComment> pageUtils = new PageUtils<>();
        int total = productCommentService.queryTotal(params);
        if (total > 0) {
            List<ProductComment> entityList = productCommentService.queryList(params);
            for (ProductComment entity : entityList) {
                if (StringUtils.isNotEmpty(entity.getImages())) {
                    List<String> imageList = Arrays.asList(entity.getImages().split(","));
                    entity.setImageList(imageList);
                }
            }
            pageUtils.setTotal(total);
            pageUtils.setRows(entityList);
        } else {
            pageUtils.setRows(new ArrayList<>());
        }
        resqVo.setPageUtils(pageUtils);

        //等级分类
        List<LevelVo> levelList = new ArrayList<>();
        LevelVo levelVo = new LevelVo();
        levelVo.setLevelName("全部");
        levelVo.setNums(total);
        levelList.add(levelVo);

        Map levelMap = new HashMap();
        levelMap.put("productId", productId);
        levelMap.put("type", params.get("type"));
        List<LevelVo> levelVoList = productCommentService.getCommentLevelCount(levelMap);
        if (null != levelVoList && levelVoList.size() > 0) {
            levelList.addAll(levelVoList);
        }
        resqVo.setLevelList(levelList);

        //商品评分
        Map map = new HashMap();
        map.put("productId", productId);
        map.put("type", type);
        BigDecimal productLevel = productCommentService.getCentreGrade(map).setScale(1, BigDecimal.ROUND_HALF_EVEN);
        resqVo.setProductLevel(productLevel);
        if (total > 0) {
            map.put("minLevel", 4);
            Integer goodReview = productCommentService.queryTotal(map);
            Integer goodRate = Math.round((goodReview * 100) / total);
            resqVo.setGoodReview(goodRate);

            map.put("minLevel", 2);
            map.put("maxLevel", 4);
            Integer mediumReview = productCommentService.queryTotal(map);
            Integer mediumRate = Math.round((mediumReview * 100) / total);
            resqVo.setMediumReview(mediumRate);

            map.put("maxLevel", 2);
            map.remove("minLevel");
            Integer badReview = productCommentService.queryTotal(map);
            Integer badRate = Math.round((badReview * 100) / total);
            resqVo.setBadReview(badRate);
        }
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", resqVo);
        return resultVo;
    }


    /**
     * 获取分享海报 后端生成
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/products/share")
    @ResponseBody
    public ResultVo getProductShareUrl(Long shopId, Long productId, String url, String teamId) throws FileNotFoundException {
        String shareUrl = productCentreService.getProductShareUrl(shopId, productId, HtmlUtils.htmlUnescape(url), teamId);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", shareUrl);
        return resultVo;
    }

    /**
     * 获取分享海报数据 前端生成
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/products/shareData")
    @ResponseBody
    public ResultVo getProductShareData(Long shopId, Long productId, String url, String teamId, Integer productType) throws FileNotFoundException {
        ProductShareVo productShareVo = productCentreService.getProductShareData(shopId, productId, HtmlUtils.htmlUnescape(url), teamId, productType);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", productShareVo);
        return resultVo;
    }

    /**
     * 获取分享海报数据 前端生成
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/products/shareData/qrCode")
    @ResponseBody
    public ResultVo getProductShareDataQrCode(Long shopId, Long productId, String url, String teamId, Integer productType) throws FileNotFoundException {
        ProductShareVo productShareVo = productCentreService.getProductShareDataQrCode(shopId, productId, HtmlUtils.htmlUnescape(url), teamId, productType);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", productShareVo);
        return resultVo;
    }


    /**
     * 获取附近门店
     */
    @RequestMapping("/nearest")
    @ResponseBody
    public ResultVo getNearestShop(Long mid, String teamName, String longitude, String latitude,
                                   Long centreId, Integer flag, String offset, String limit) {
        List<Member> shops = memberService.getNearCommanders(Double.valueOf(longitude), Double.valueOf(latitude), teamName,
                centreId, mid, flag, 0, Integer.parseInt(limit));
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", shops);
        return resultVo;
    }

    /**
     * 获取门店
     */
    @RequestMapping("")
    @ResponseBody
    @Auth
    public ResultVo getShopInfo(Long id) {
        Member shop = memberService.getDetail(id);

        if (shop.getIsteam() != 3) {
            return ResultVo.error("门店已经关闭");
        }

        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", shop);
        return resultVo;
    }

//    /**
//     * 绑定门店
//     *
//     * @author kanghaixin
//     * @date 2018/9/7.15:39
//     */
//    @RequestMapping("/bind")
//    @ResponseBody
//    @Auth(arg = 0)
//    public ResultVo bindShop(Long memberId, Long teamId) {
//        Long result = memberService.bindTeam(memberId, teamId);
//
//        if (result == null) {
//            return ResultVo.error();
//        }
//
//        ResultVo resultVo = new ResultVo();
//        resultVo.put("success", true);
//        resultVo.put("data", result);
//        return resultVo;
//    }

    /**
     * 轮播接口
     *
     * @param reqDto
     * @return
     */
    @RequestMapping("/banners")
    @ResponseBody
    public ResultVo getShopBanners(BannersReqDto reqDto) {
        if (reqDto.getMid() != null) {
            Member member = memberService.getByKey(reqDto.getMid());
            if (member != null) {
                if (StringUtils.isNotEmpty(member.gettProvince())) {
                    reqDto.setProvince(member.gettProvince());
                }
                if (StringUtils.isNotEmpty(member.gettCity())) {
                    reqDto.setCity(member.gettCity());
                }
                if (StringUtils.isNotEmpty(member.gettArea())) {
                    reqDto.setArea(member.gettArea());
                }
            }
        }
        List<AdvertVo> banners = advertService.listAdverts(reqDto);
        if (banners.size() <= 0) {
            reqDto.setTeamId(null);
            banners = advertService.listAdverts(reqDto);
        }
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", banners);
        return resultVo;
    }

    /**
     * 获取商品分类信息
     */
    @RequestMapping("/subject")
    @ResponseBody
    public ResultVo getShopSubject(Long parentId, Integer type, Long centreId, Long liansuoId) {
        List<Category> categories = null;
        if (centreId != null) {
            categories = categoryService.listCategorys(0L, type, centreId, liansuoId);
        } else {
            Category category = new Category();
            category.setType(type);
            category.setParentid(0L);
            category.setCentreId(null);
            categories = categoryService.getListCategory(category);
        }
        if (categories.isEmpty()) {
            Category category = new Category();
            category.setType(type);
            category.setParentid(0L);
            category.setCentreId(null);
            categories = categoryService.getListCategory(category);
        }

        if (categories.isEmpty()) {
            return ResultVo.error("没有找到首页分类信息");
        }

       /* if(categories.get(0).getId().longValue()==630716 || categories.get(0).getName().equals("活动专区")) {
            categories = categoryService.listCategorys(0L, type);
        }else {
            categories = categoryService.listCategorys(categories.get(0).getId(), type);
        }*/
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", categories);
        return resultVo;
    }

    /**
     * 添加访问次数
     */
    @RequestMapping("/access/log")
    @ResponseBody
    @Auth
    public ResultVo addAccessLog(AccessLog log) {
        int result = memberService.saveAccessLog(log);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", result);
        return resultVo;
    }

    /**
     * 首页公告
     */
    @RequestMapping("/notice")
    @ResponseBody
    public ResultVo getShopNotice(Long centerId) {
        PageUtils<Notice> notices = noticeService.listNotices(centerId, 0, 20);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", notices);
        return resultVo;
    }

//    /**
//     * 门店提货清单
//     */
//    @RequestMapping("/pickup/list")
//    @ResponseBody
//    @Auth(arg = 0)
//    public ResultVo getPickupList(Long shopId, int offset, int limit) {
//        PageUtils<CargoListVo> lists = nodirectService.getCargoLists(shopId, offset, limit);
//        ResultVo resultVo = new ResultVo();
//        resultVo.put("success", true);
//        resultVo.put("data", lists);
//        return resultVo;
//    }
//
//    /**
//     * 提货清单详情
//     */
//    @RequestMapping("/pickup/detail")
//    @ResponseBody
//    @Auth
//    public ResultVo getPickupDetail(Long listId, Long shopId) {
//        Map<String, Object> detail = nodirectService.getCargoListDetail(listId, shopId);
//        ResultVo resultVo = new ResultVo();
//        resultVo.put("success", true);
//        resultVo.put("data", detail);
//        return resultVo;
//    }
//
//    /**
//     * 确认提货
//     */
//    @RequestMapping("/pickup/confirm")
//    @ResponseBody
//    @Auth
//    public ResultVo confirmPickup(Long listId, Long shopId, Long memberId) {
//        int result = nodirectService.pickCargoProduct(listId, shopId, memberId);
//        ResultVo resultVo = new ResultVo();
//        resultVo.put("success", true);
//        resultVo.put("data", result);
//        return resultVo;
//    }

    /**
     * 门店列表
     * 获取附近门店，原来的门店经纬度使用的是用户的，Sass版本的需要门店单独的坐标
     * 所以，新增加一个方法来获取门店的列表
     */
    @RequestMapping("/newNearest")
    @ResponseBody
    public ResultVo getNewNearestShop(Long mid, String teamName, String longitude, String latitude,
                                      Long centreId, Integer flag, Integer terminalIds, String offset, String limit, Integer isLocalLifeStoreFlag, Integer isAppletsStoreFlag, Long industryBrandId) throws ParseException {
        List<Member> shops = memberService.getNewNearCommanders(Double.valueOf(longitude), Double.valueOf(latitude), teamName,
                centreId, mid, flag, terminalIds, 0, Integer.parseInt(limit), isLocalLifeStoreFlag, isAppletsStoreFlag, industryBrandId);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", shops);
        return resultVo;
    }

    /**
     * 注册门店
     */
    @RequestMapping("/reg")
    @ResponseBody
//	@Auth
    public ResultVo regShop(Member shop) {
        int result = memberService.registTeam(shop);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", result);
        return resultVo;
    }

    /**
     * 门店统计
     */
    @RequestMapping("/statistic")
    @ResponseBody
    @Auth
    public ResultVo getShopStatistic(ShopCountParams params, int limit, int offset) {
        Map<String, Object> shopCount = orderService.shopCount(params, limit, offset);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", shopCount);
        return resultVo;
    }

    /**
     * 门店排行
     */
    @RequestMapping("/ranking")
    @ResponseBody
    @Auth
    public ResultVo getShopRanking(Long shopId, Integer type) {
        Map<String, Object> rankings = memberService.getShopRankings(shopId, type);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", rankings);
        return resultVo;
    }


    /**
     * 获取门店会员
     */
    @RequestMapping("/members")
    @ResponseBody
    @Auth(arg = 0)
    public ResultVo getShopMembers(Long shopId, int offset, int limit, String queryItem) {
        PageUtils<Member> members = memberService.listTeamMembers(shopId, queryItem, offset, limit);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", members);
        return resultVo;
    }

    /**
     * 首页底部
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/footer")
    @ResponseBody
    public ResultVo getShopFooter(Long centerId) {
        FooterConfig footerConfig = configService.getFooterConfig(centerId);
        BaseConfig baseConfig = configService.getBaseConfig();
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        JSONObject footer = new JSONObject();

        if (baseConfig.getCustomQrCodeUrl() != null) {
            footer.put("qrcode", baseConfig.getCustomQrCodeUrl());
        }

        JSONArray phones = new JSONArray();
        footer.put("phones", phones);
        addFooterPicTel(phones, baseConfig.getJoinPic(), baseConfig.getJoinTel());

        if (footerConfig != null) {
            addFooterPicTel(phones, footerConfig.getTeamRecruitPic(), footerConfig.getTeamRecruitTel());
            addFooterPicTel(phones, footerConfig.getProductInvestmentPic(), footerConfig.getProductInvestmentTel());
            addFooterPicTel(phones, footerConfig.getSupervisePic(), footerConfig.getSuperviseTel());
        }

        resultVo.put("data", footer);
        return resultVo;
    }

    private void addFooterPicTel(JSONArray phones, String pic, String tel) {
        if ((pic != null) && (tel != null)) {
            JSONObject phone = new JSONObject();
            phone.put("url", pic);
            phone.put("value", tel);
            phones.add(phone);
        }
    }


    /**
     * 获取商品列表
     *
     * @author kanghaixin
     * @date 2018/9/7.15:39
     */
    @RequestMapping("/products")
    @ResponseBody
    public ResultVo getShopProducts(ProductsReqVo reqVo, Integer offset, Integer limit) {
        PageUtils<ProductCentre> products = productCentreService.getListCentreProducts(offset, limit, reqVo);
        ResultVo resultVo = new ResultVo();
        resultVo.put("success", true);
        resultVo.put("data", products);
        return resultVo;
    }



}
